/**
 * All rights Reserved, Designed By senior.auto
 *
 * @Title: MyBatisMapperScannerConfig.java
 * @Package com.example.demo.config
 * @Description: MyBatisMapperScanner扫描配置类
 * @author: xiongzhengsheng
 * @date: 2021年1月12日 下午8:27:16
 * @version: V1.0
 * @Copyright: 2021 senior.auto Inc. All rights reserved.
 */
package com.example.demo.config;

import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @ClassName: MyBatisMapperScannerConfig
 * @Description: MyBatisMapperScanner扫描配置类
 * @author: xiongzhengsheng
 * @date: 2021年1月12日 下午8:29:51
 * @Copyright: 2021 senior.auto Inc. All rights reserved.
 *
 */
@Configuration
//必须在MyBatisConfig注册后再加载MapperScannerConfigurer，否则会报错
@AutoConfigureAfter(DataSourceConfig.class)
public class MyBatisMapperScannerConfig {

    /**
     * @Title: mapperScannerConfigurer
     * @Description: MapperScannerConfigurer 实例bean
     * @return: MapperScannerConfigurer 返回类型
     * @throws
     */
    @Bean
    public static MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
        mapperScannerConfigurer.setBasePackage("com.example.demo.mapper");
        mapperScannerConfigurer.setMarkerInterface(BaseMapper.class);
//		mapperScannerConfigurer.set
//		Properties properties = new Properties();
//		properties.setProperty("mappers", BaseMapper.class.getName());//MyMapper这个类接下来会创建
//		properties.setProperty("notEmpty", "false");
//		properties.setProperty("IDENTITY", "MYSQL");
//		//特别注意mapperScannerConfigurer的引入import tk.mybatis.spring.mapper.MapperScannerConfigurer;引入错误则没下面这个方法
//		mapperScannerConfigurer.setProperties(properties);
        return mapperScannerConfigurer;
    }

}
